package com.list;

public class Test2 {
    public static ListNode removeNthFromEnd(ListNode head, int n) {
       ListNode p1=head;
        for (int i = 0; i < n; i++) {
            p1=p1.next;
        }
        ListNode p2=head;
        while (p2!=null){
            p1=p1.next;
            p2=p2.next;
        }
        p2.next=p2.next.next;
        return p2;
        

    }
}
